package com.rs.portal.commons;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import com.rs.rsbiz.reserve.delegate.ReserveDelegate;

public class ExceptionHandler implements HandlerExceptionResolver
{
    private Log log = LogFactory.getLog(ReserveDelegate.class);

    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
    {
        System.out.println(ex.toString());
        log.error("url:" + request.getRequestURL(), ex);
        // return new
        // ModelAndView("redirect:/web2/indexAction.do?method=index");
        String requestUri = request.getRequestURI();
        Map attrs = new HashMap();
        attrs.put("message", "您访问页面出现错误.");
        
        if (requestUri.toLowerCase().indexOf("wap") > 0)
        {
            return new ModelAndView("error", attrs);
        }
        else
        {
            return new ModelAndView("error", attrs);
        }
    }
}
